#ifndef Minesweeper_H
#define Minesweeper_H

#include <vector>
#include <QGraphicsItem>
#include "SVector2D.h"
#include "CNeuralNet.h"
#include "mines.h"
#include "CParams.h"

using namespace std;

 class Minesweeper : public QGraphicsItem
 {
 private:
     qreal angle;
     qreal speed;
     qreal MinesweeperEyeDirection;
     QColor color;
     QPen  pen;
     //its rotation (surprise surprise)
     double			m_dRotation;

     double			m_dSpeed;

     //to store output from the ANN
     double			m_lTrack, m_rTrack;

     //the sweeper's fitness score
     double			m_dFitness;

     //the scale of the sweeper when drawn
     double			m_dScale;

     //index position of closest mine
     int         m_iClosestMine;

     //the minesweeper's neural net
     CNeuralNet		m_ItsBrain;

     //its position in the world
     SVector2D		m_vPosition;

     //direction sweeper is facing
     SVector2D		m_vLookAt;

     vector<SVector2D> sV_mines;
     mines **mineArray;

 public:
     Minesweeper();

     QRectF boundingRect() const;
     QPainterPath shape() const;
     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                QWidget *widget);

     SVector2D GetCloseMine(vector<SVector2D> &v_mines);
     SVector2D	GetClosestMine(vector<SVector2D> &objects);
     vector<double> getWeights();
     double getFitness();

     void update();
     void setMines(vector<SVector2D> v_mines);
     void increaseFitness(int num);
     void setPen(QPen p);
     void Reset();
     void putWeights(vector<double> &w){m_ItsBrain.PutWeights(w);}
     void setPosition(SVector2D p);
     int  GetNumOfWeights()const {return m_ItsBrain.GetNumberOfWeights();}
 };

 #endif
